Skip to content

fix(chat): load message history on first conversation click#730

Merged
viettranx merged 2 commits intonextlevelbuilder:devfrom
kaitranntt:kai/fix/729-chat-first-click-no-messages
Apr 7, 2026
Merged

fix(chat): load message history on first conversation click#730
viettranx merged 2 commits intonextlevelbuilder:devfrom
kaitranntt:kai/fix/729-chat-first-click-no-messages

Conversation

@kaitranntt
Copy link
Copy Markdown
Contributor

@kaitranntt kaitranntt commented Apr 6, 2026

Problem

Clicking a conversation from the Chat page's initial state (no session selected) does not load messages. The URL updates, sidebar highlights the conversation, but the main area shows "Start a conversation" placeholder. Only after clicking a different conversation do messages load.

Closes #729

Visual Review

Full comparison report

Chat — First Click from Clean State

Before After
Before After

Before: Clicking "Chat a95c8ffa" from initial state — conversation highlighted but main area shows empty "Start a conversation" placeholder.
After: Same click — conversation messages load immediately on first click.

All captures: same instance (claw backend), same user (kai/Master), same agent (glm thục bô), same conversation. Callout borders mark the review area.

Root Cause

skipNextHistoryRef was unconditionally set to true whenever sessionKey transitioned from empty to non-empty (line 61 in use-chat-messages.ts). This skip was intended only for the new-chat send flow, where an optimistic user message is already displayed and loadHistory() would race with chat.send. However, it also fired when clicking an existing conversation from the sidebar — preventing loadHistory() from running.

What changed

File Change
ui/web/src/pages/chat/hooks/use-chat-messages.ts Guard skipNextHistoryRef with expectingRunRef.current check

Validation

  • pnpm run build passes
  • Bug reproduced via Playwright against live GoClaw instance
  • RPC log confirmed chat.history was never called on first click
  • Fix verified via local dev server — messages load on first click
  • New-chat send flow preserved (expectingRunRef is set by useChatSend before ws.call)
  • Before/after UI evidence captured with matching state

…from clean state

The skipNextHistoryRef was unconditionally set when sessionKey transitioned
from empty to non-empty. This prevented loadHistory() from running when
clicking an existing conversation from the initial /chat page. The skip
was only intended for the new-chat send flow where the optimistic message
is already displayed.

Guard the skip with expectingRunRef so it only activates when a message
send is in flight.

Closes nextlevelbuilder#729
Before/after screenshots and HTML comparison report showing
first conversation click behavior fix.
@viettranx viettranx merged commit e22a870 into nextlevelbuilder:dev Apr 7, 2026
2 checks passed
viettranx pushed a commit that referenced this pull request Apr 7, 2026
* fix(chat): load message history when selecting existing conversation from clean state

The skipNextHistoryRef was unconditionally set when sessionKey transitioned
from empty to non-empty. This prevented loadHistory() from running when
clicking an existing conversation from the initial /chat page. The skip
was only intended for the new-chat send flow where the optimistic message
is already displayed.

Guard the skip with expectingRunRef so it only activates when a message
send is in flight.

Closes #729

* docs: add UI diff evidence for PR #730

Before/after screenshots and HTML comparison report showing
first conversation click behavior fix.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: first conversation click from clean state does not load messages

2 participants